package cn.b.sky.mes.pp.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import cn.b.sky.mes.pp.dao.OperationTaskDao;
import cn.b.sky.mes.pp.dao.ProductOrderDao;
import cn.b.sky.mes.pp.dao.ProductionControlDao;
import cn.b.sky.mes.pp.dao.ProductionOrderDao;
import cn.b.sky.mes.pp.enums.OperationTaskStatus;
import cn.b.sky.mes.pp.enums.OrderStatusCode;
import cn.b.sky.mes.pp.enums.PorderStatusCode;
import cn.b.sky.mes.pp.enums.ProductionControlStatusCode;
import cn.b.sky.mes.pp.model.condition.ProductionControlCondition;
import cn.b.sky.mes.pp.model.condition.ProductionControlStatesCondition;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import cn.b.sky.mes.cm.dao.ProcessOperationDao;
import cn.b.sky.mes.cm.enums.OperationType;
import cn.b.sky.mes.cm.model.ProcessOperation;
import cn.b.sky.common.model.BatchJobReport;
import cn.b.sky.common.model.ImeCommon;
import cn.b.sky.common.utils.DatabaseUtils;
import cn.b.sky.i18n.utils.LocaleResourceBundle;
import cn.b.sky.user.SecurityContextUtil;
import cn.b.sky.mes.cm.enums.ECodeEnums;
import cn.b.sky.mes.cm.enums.NumberRuleEnums;
import cn.b.sky.user.service.ECodeService;
import cn.b.sky.user.service.NumberRuleService;
import cn.b.sky.user.service.model.ECode;
import cn.b.sky.mes.pp.model.OperationTask;
import cn.b.sky.mes.pp.model.ProductOrder;
import cn.b.sky.mes.pp.model.ProductionControl;
import cn.b.sky.mes.pp.model.ProductionOperation;
import cn.b.sky.mes.pp.model.ProductionOrder;
import cn.b.sky.mes.pp.service.ProductionControlService;

/**
 * 
 * <strong>Title : ProductionControlServiceImpl.java<br></strong>
 * <strong>Package : cn.b.sky.mes.pp.service.impl<br></strong>
 * <strong>Description : </strong>生产管理号业务实现<br> 
 * <strong>Create on : 2016年5月13日 上午10:49:58<br></strong>
 * <p>
 * @author zhaoxin01<br>
 * @version <strong>v1.0.0</strong><br>
 * <br>
 * <strong>修改历史:</strong><br>
 * 修改人|修改日期|修改描述<br>
 * -------------------------------------------<br>
 * <br>
 * <br>
 */
@Service("productionControlService")
public class ProductionControlServiceImpl implements ProductionControlService {

  private static final Logger LOGGER = LoggerFactory.getLogger(ProductionControlServiceImpl.class);

  @Resource
  ProductionControlDao productionControlDao;

  @Resource
  ProductionOrderDao productionOrderDao;

  @Resource
  ProductOrderDao productOrderDao;

  @Resource
  ProcessOperationDao processOperationDao;

  @Resource
  ECodeService eCodeService;

  @Resource
  OperationTaskDao operationTaskDao;

  @Resource
  NumberRuleService numberRuleService;

  @Override
  public List<ProductionControl> selectProductionControlByCondition(
      ProductionControlCondition productionControlCondition) {
    if (productionControlCondition == null) {
      return null;
    }
    return productionControlDao.selectProductionControlByCondition(productionControlCondition);
  }

  @Override
  public int selectProductionControlCount(ProductionControlCondition productionControlCondition) {
    if (productionControlCondition == null) {
      return 0;
    }
    return productionControlDao.selectProductionControlCount(productionControlCondition);
  }

  @Override
  public ProductionControl selectProductionControl(String siteCode, String productionControlNum) {
    if (StringUtils.isBlank(siteCode) || StringUtils.isBlank(productionControlNum)) {
      return null;
    }
    return productionControlDao.selectProductionControl(siteCode, productionControlNum);
  }

  @Override
  public void updateProductionControl(ProductionControl productionControl) {
    if (productionControl != null) {
      productionControlDao.updateProductionControl(productionControl);
    }

  }

  @Override
  public BatchJobReport deleteProductionControl(String siteCode, String productionControlNum) {
    String cause = "";
    Boolean success = true;
    try {
      ProductionControl productionControl = productionControlDao.selectProductionControl(siteCode,
          productionControlNum);
      if (productionControl.getStatuseCode().equals(ProductionControlStatusCode.CREATE.getValue())) {
        //未投产的生产管理号才可以删除
        //如果需要工序派工则先删除已产生的工序任务单 add by zhaoxin 20160801
        if (productionControl.getOperationScheduleFlag() == 1) {
          operationTaskDao.deleteOperationTaskByProductionControl(siteCode, productionControlNum);
        }
        productionControlDao.deleteProductionControl(siteCode, productionControlNum);
        //获得对应生产订单
        ProductionOrder productionOrder = productionOrderDao.selectProductionOrdersByPk(siteCode,
            productionControl.getProductionOrderNum());
        ProductionOrder updateInfo = new ProductionOrder();
        updateInfo.setSiteCode(siteCode);
        updateInfo.setProductionOrderNum(productionControl.getProductionOrderNum());
        //更新对应生产订单的已下达数量
        double releasedQuantity = productionOrder.getReleasedQuantity() - productionControl.getPlannedQuantity();
        updateInfo.setReleasedQuantity(releasedQuantity);
        //如果已下达数量扣减为0 则生产订单变成创建状态
        if (releasedQuantity == 0.0d) {
          updateInfo.setStatuseCode(OrderStatusCode.CREATE.getValue());
        }
        setChangeInfo(updateInfo);
        productionOrderDao.updateProductionOrder(updateInfo);
      } else {
        success = false;
        cause = LocaleResourceBundle.getCommonResourceLabel(SecurityContextUtil.getSiteCode(),
            SecurityContextUtil.getLanguageCode(), "productionControlHasPlace.M");
      }
    } catch (Exception e) {
      LOGGER.error("{}", e);
      TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
      if (DatabaseUtils.isConstraintsError(e.getMessage())) {
        // 外键删除已存在提示
        cause = LocaleResourceBundle.getCommonResourceLabel(SecurityContextUtil.getSiteCode(),
            SecurityContextUtil.getLanguageCode(), "dataBaseOperationPkFail.M")
            + LocaleResourceBundle.getCommonResourceLabel(SecurityContextUtil.getSiteCode(),
                SecurityContextUtil.getLanguageCode(), "notDelete.M");
      } else {
        cause = e.getMessage();
      }
      success = false;
    }
    return new BatchJobReport(productionControlNum, cause, success);
  }

  @Override
  public BatchJobReport doCloseProductionControl(String siteCode, String productionControlNum,
      Boolean closeOperationTask) {
    String cause = "";
    Boolean success = true;
    try {
      ProductionControl productionControl = productionControlDao.selectProductionControl(siteCode,
          productionControlNum);
      if (productionControl.getStatuseCode().equals(ProductionControlStatusCode.CLOSE.getValue())) {
        success = false;
        cause = LocaleResourceBundle.getCommonResourceLabel(SecurityContextUtil.getSiteCode(),
            SecurityContextUtil.getLanguageCode(), "productionControlHasClosed.M");
      } else if (productionControl.getStatuseCode().equals(ProductionControlStatusCode.COMPLETE.getValue())) {
        success = false;
        cause = LocaleResourceBundle.getCommonResourceLabel(SecurityContextUtil.getSiteCode(),
            SecurityContextUtil.getLanguageCode(), "productionControlHasComplete.M");
      } else {
        //关闭、完工状态以外的生产管理号才可以关闭
        //如果需要工序派工则先关闭非完工和非强制关闭的工序任务单 add by zhaoxin 20160801
        if (productionControl.getOperationScheduleFlag() == 1 && closeOperationTask) {
          OperationTask operationTask = new OperationTask();
          operationTask.setSiteCode(siteCode);
          operationTask.setProductionControlNum(productionControlNum);
          operationTask.setStatusECode(OperationTaskStatus.CLOSE.getValue());
          operationTask.setStatusECode1(OperationTaskStatus.CLOSE.getValue());
          operationTask.setStatusECode2(OperationTaskStatus.COMPLETE.getValue());
          setChangeInfo(operationTask);
          operationTaskDao.updateOperationTaskCloseByProductionControl(operationTask);
        }

        //关闭生产管理号
        productionControl.setStatuseCode(ProductionControlStatusCode.CLOSE.getValue());
        setChangeInfo(productionControl);
        productionControlDao.updateProductionControl(productionControl);
        //如果生产订单下的所有生产管理号都已经关闭或完工，则生产订单变为关闭
        List<String> controlStatusSet = new ArrayList<String>();
        controlStatusSet.add(ProductionControlStatusCode.CREATE.getValue());
        controlStatusSet.add(ProductionControlStatusCode.ISSUED.getValue());
        controlStatusSet.add(ProductionControlStatusCode.PRODUCT.getValue());
        controlStatusSet.add(ProductionControlStatusCode.SUBMIT.getValue());
        int count = productionControlDao.selectProductionControlCountByStatusSet(siteCode,
            productionControl.getProductionOrderNum(), controlStatusSet);
        if (count == 0) {
          //更新生产订单状态为关闭
          doCloseProductionOrder(siteCode, productionControl);
        }
      }
    } catch (Exception e) {
      LOGGER.error("{}", e);
      TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
      cause = e.getMessage();
      success = false;
    }
    return new BatchJobReport(productionControlNum, cause, success);
  }

  private void setChangeInfo(ImeCommon imeCommon) {
    imeCommon.setModifyDateTime(new Date());
    imeCommon.setModifyUser(SecurityContextUtil.getCurrentUserName());
  }

  /**
   * 
   * <strong>Title : doCloseProductionOrder<br></strong>
   * <strong>Description : </strong>关闭生产订单<br> 
   * <strong>Create on : 2016年5月17日 上午11:25:13<br></strong>
   * <p>
   * @param siteCode
   * @param productionControl
   * void
   * @throws 
   * @author zhaoxin01<br>
   * @version <strong>v1.0.0</strong><br>
   * <br>
   * <strong>修改历史:</strong><br>
   * 修改人 | 修改日期 | 修改描述<br>
   * -------------------------------------------<br>
   * <br>
   * <br>
   */
  private void doCloseProductionOrder(String siteCode, ProductionControl productionControl) {
    ProductionOrder updateInfo = new ProductionOrder();
    updateInfo.setSiteCode(siteCode);
    updateInfo.setProductionOrderNum(productionControl.getProductionOrderNum());
    updateInfo.setStatuseCode(OrderStatusCode.CLOSE.getValue());
    setChangeInfo(updateInfo);
    productionOrderDao.updateProductionOrder(updateInfo);
    ProductionOrder productionOrder = productionOrderDao.selectProductionOrdersByPk(siteCode,
        productionControl.getProductionOrderNum());
    //如果产品订单下的所有生产订单都已经关闭或完工，则产品订单变为关闭
    if (!StringUtils.isBlank(productionOrder.getProductOrderNum())) {
      List<String> orderStatusSet = new ArrayList<String>();
      orderStatusSet.add(OrderStatusCode.CREATE.getValue());
      orderStatusSet.add(OrderStatusCode.PLACE_ORDER.getValue());
      int count = productionOrderDao.selectOrderCountByStatusSet(siteCode, productionOrder.getProductOrderNum(),
          orderStatusSet);
      if (count == 0) {
        doCloseProductOrder(siteCode, productionOrder);
      }
    }
  }

  /**
   * 
   * <strong>Title : doCloseProductOrder<br></strong>
   * <strong>Description : </strong>关闭产品订单<br> 
   * <strong>Create on : 2016年5月17日 上午11:23:53<br></strong>
   * <p>
   * @param siteCode
   * @param productionControl
   * void
   * @throws 
   * @author zhaoxin01<br>
   * @version <strong>v1.0.0</strong><br>
   * <br>
   * <strong>修改历史:</strong><br>
   * 修改人 | 修改日期 | 修改描述<br>
   * -------------------------------------------<br>
   * <br>
   * <br>
   */
  private void doCloseProductOrder(String siteCode, ProductionOrder productionOrder) {
    ProductOrder productOrder = new ProductOrder();
    productOrder.setSiteCode(siteCode);
    productOrder.setProductOrderNum(productionOrder.getProductOrderNum());
    productOrder.setStatuseCode(PorderStatusCode.CLOSE.getValue());
    setChangeInfo(productOrder);
    productOrderDao.updateNoCreateProductOrder(productOrder);
  }

  @Override
  public BatchJobReport doPlaceOrderProductionControl(String siteCode, String productionControlNum) {
    ProductionControl productionControl = productionControlDao.selectProductionControl(siteCode, productionControlNum);
    String cause = "";
    Boolean success = true;

    // 检查生产管理是否已经投产
    if (!productionControl.getStatuseCode().equals(ProductionControlStatusCode.CREATE.getValue())) {
      success = false;
      cause = LocaleResourceBundle.getCommonResourceLabel(SecurityContextUtil.getSiteCode(),
          SecurityContextUtil.getLanguageCode(), "productionControlHasPlace.M");
    } else if (productionControl.getOperationScheduleFlag() == 1) {
      //工序派工类型的订单不可以投产
      success = false;
      cause = LocaleResourceBundle.getCommonResourceLabel(SecurityContextUtil.getSiteCode(),
          SecurityContextUtil.getLanguageCode(), "operationScheduleCanNotPlace.M");
    } else {
      String operationTypeECode = OperationType.PRODUCTION.getValue();
      // 查询工序类型为生产的工艺工序
      List<ProcessOperation> processOperationList = processOperationDao.selectConfirmationProcessOperation(siteCode,
          productionControl.getProductionOrderNum(), operationTypeECode);

      if (processOperationList.size() > 0) {
        // 插入生产确认点工序
        for (ProcessOperation po : processOperationList) {
          insertProductionOperation(siteCode, productionControlNum, productionControl, po);
        }

        // 改变生产管理号状态为投产、设置实际开始时间
        productionControl.setStatuseCode(ProductionControlStatusCode.PRODUCT.getValue());
        productionControl.setActualstartDateTime(new Date());
        //更新生产管理号
        setChangeInfo(productionControl);
        productionControlDao.updateProductionControl(productionControl);
        //查询生产订单
        ProductionOrder productionOrder = productionOrderDao.selectProductionOrdersByPk(siteCode,
            productionControl.getProductionOrderNum());
        if (productionOrder.getActualstartDateTime() == null) {
          //更新计划开始时间
          updateActualStartDateTime(siteCode, productionOrder);
        }
      } else {
        // 无生产类型工序
        success = false;
        cause = LocaleResourceBundle.getCommonResourceLabel(SecurityContextUtil.getSiteCode(),
            SecurityContextUtil.getLanguageCode(), "thisOrderHasNoOperationOfProduction.M");
      }
    }

    return new BatchJobReport(productionControlNum, cause, success);

  }

  /**
   * 
   * <strong>Title : updateActualStartDateTime<br></strong>
   * <strong>Description : </strong>设置计划开始时间<br> 
   * <strong>Create on : 2016年5月17日 下午6:38:25<br></strong>
   * <p>
   * @param siteCode
   * @param productionOrder
   * void
   * @throws 
   * @author zhaoxin01<br>
   * @version <strong>v1.0.0</strong><br>
   * <br>
   * <strong>修改历史:</strong><br>
   * 修改人 | 修改日期 | 修改描述<br>
   * -------------------------------------------<br>
   * <br>
   * <br>
   */
  private void updateActualStartDateTime(String siteCode, ProductionOrder productionOrder) {
    //设置生产订单实际开始时间
    Date now = new Date();
    productionOrder.setActualstartDateTime(now);
    setChangeInfo(productionOrder);
    productionOrderDao.updateProductionOrder(productionOrder);
    //查询产品订单
    if (!StringUtils.isBlank(productionOrder.getProductOrderNum())) {
      ProductOrder productOrder = productOrderDao.selectProductOrdersByPk(siteCode,
          productionOrder.getProductOrderNum());
      if (productOrder.getActualstartDateTime() == null) {
        //设置产品订单实际开始实际
        productOrder.setActualstartDateTime(now);
        setChangeInfo(productOrder);
        productOrderDao.updateNoCreateProductOrder(productOrder);
      }
    }
  }

  /**
   * 
   * <strong>Title : insertProductionOperation<br></strong>
   * <strong>Description : </strong>插入生产确认点工序<br> 
   * <strong>Create on : 2016年5月17日 下午6:36:41<br></strong>
   * <p>
   * @param siteCode
   * @param productionControlNum
   * @param productionControl
   * @param po
   * void
   * @throws 
   * @author zhaoxin01<br>
   * @version <strong>v1.0.0</strong><br>
   * <br>
   * <strong>修改历史:</strong><br>
   * 修改人 | 修改日期 | 修改描述<br>
   * -------------------------------------------<br>
   * <br>
   * <br>
   */
  private void insertProductionOperation(String siteCode, String productionControlNum,
      ProductionControl productionControl, ProcessOperation po) {
    ProductionOperation productionOperation = new ProductionOperation();
    productionOperation.setSiteCode(siteCode);
    productionOperation.setProductionControlNum(productionControlNum);
    productionOperation.setOperationCode(po.getOperationCode());
    productionOperation.setProcessOperationId(po.getId());
    productionOperation.setPlannedQuantity(productionControl.getPlannedQuantity());
    productionOperation.setCreateDateTime(new Date());
    productionOperation.setCreateUser(SecurityContextUtil.getCurrentUserName());
    setChangeInfo(productionOperation);
    productionControlDao.insertProductionOperation(productionOperation);
  }

  @Override
  public List<ProductionControl> selectProductionControlsByOrderNum(String siteCode, String productionOrderNum) {
    if (StringUtils.isBlank(siteCode) || StringUtils.isBlank(productionOrderNum)) {
      return new ArrayList<ProductionControl>();
    }
    return productionControlDao.selectProductionControlsByOrderNum(siteCode, productionOrderNum);
  }

  @Override
  public Map productionControlStatusList(ProductionControlStatesCondition condition) {
    if (condition == null) {
      condition = new ProductionControlStatesCondition();
    }
    condition.setOrderField("CreateDateTime");
    HashMap<String, Integer> controlStatus = new HashMap<String, Integer>();
    int totalCount = 0;
    List<ECode> ecodes = eCodeService.selectECodeList(ECodeEnums.PRODUCTIONCONTROL_STATUS.getCode(),
        SecurityContextUtil.getLanguageCode());
    String[] statuseCodes = new String[ecodes.size()];
    for (int i = 0; i < ecodes.size(); i++) {
      statuseCodes[i] = ecodes.get(i).geteCode();
    }
    condition.setStatuseCodes(statuseCodes);
    Set<Map<String, Object>> set = productionControlDao.getProductionControlStatusByCondition(condition);
    for (Map<String, Object> map : set) {
      Integer count = Integer.valueOf(map.get("COUNT").toString());
      controlStatus.put(map.get("STATUSECODE").toString(), count);
      totalCount += count;
    }

    //逾期未完工
    condition.setStatuseCodes(
        new String[] { ProductionControlStatusCode.PRODUCT.getValue(), ProductionControlStatusCode.SUBMIT.getValue(),
            ProductionControlStatusCode.CREATE.getValue(), ProductionControlStatusCode.ISSUED.getValue() });
    controlStatus.put("uncompleteCount", productionControlDao.getUncompletedCount(condition));
    controlStatus.put("totalCount", totalCount);
    condition.setStatuseCodes(new String[] {});
    return controlStatus;
  }

  @Override
  public List<ProductionControl> selectproductionControlStatusBycondition(String status,
      ProductionControlStatesCondition condition) {
    condition.setOrderField("CreateDateTime");
    if (StringUtils.isBlank(condition.getStatuseCode())) {
      condition.setStatuseCode(status);
    }
    List<ProductionControl> list = productionControlDao.selectProductionControlStatusByCondition(condition);
    if (StringUtils.isBlank(status)) {
      List<ProductionControl> filterlList = new ArrayList<>();
      for (ProductionControl pc : list) {
        if (pc.getPlannedendDateTime().before(new Date())
            && !pc.getStatuseCode().equals(ProductionControlStatusCode.COMPLETE.getValue())
            && !pc.getStatuseCode().equals(ProductionControlStatusCode.CLOSE.getValue())) {
          filterlList.add(pc);
        }
      }
      return filterlList;
    }
    return list;
  }

  @Override
  public int selectProductionControlStatusCountBycondition(ProductionControlStatesCondition condition) {
    condition.setOrderField("CreateDateTiaame");
    return productionControlDao.selectProductionControlStatusCountBycondition(condition);
  }

  @Override
  public List<ProductionControl> selectProductionControlListForDefectGraph(
      ProductionControlCondition productionControlCondition) {
    return productionControlDao.selectProductionControlListForDefectGraph(productionControlCondition);
  }

  @Override
  public void closeProductionControl(String siteCode, String orderNum, String type) {

    if (StringUtils.isBlank(siteCode) || StringUtils.isBlank(orderNum)) {
      return;
    }
    ProductionControl control = new ProductionControl();
    control.setSiteCode(siteCode);
    setChangeInfo(control);
    control.setStatuseCode(ProductionControlStatusCode.CLOSE.getValue());
    //去掉已完成状态
    control.setStatusECode1(ProductionControlStatusCode.COMPLETE.getValue());
    if ("productionOrder".equals(type)) {
      control.setProductionOrderNum(orderNum);
      List<ProductionControl> controls = productionControlDao
          .selectCanClosedProductionControlByProductionOrder(control);
      if (controls != null && controls.size() > 0) {
        this.closeProductionControlByProductionOrder(control);
      }
      return;
    } else if ("productOrder".equals(type)) {
      control.setProductOrderNum(orderNum);
      List<ProductionControl> controls = productionControlDao.selectCanClosedProductionControlByProductOrder(control);
      if (controls != null && controls.size() > 0) {
        this.closeProductionControlByProductOrder(control);
      }
    }
  }

  private void closeProductionControlByProductOrder(ProductionControl control) {
    OperationTask task = new OperationTask();
    task.setProductOrderNum(control.getProductOrderNum());
    task.setSiteCode(control.getSiteCode());
    task.setStatusECode(OperationTaskStatus.CLOSE.getValue());
    task.setStatusECode1(OperationTaskStatus.COMPLETE.getValue());
    setChangeInfo(task);
    List<OperationTask> tasks = operationTaskDao.selectCanClosedOperationTaskByProductOrder(task);
    if (tasks != null && tasks.size() > 0) {
      operationTaskDao.closeOperationTaskByProductOrder(task);
    }
    productionControlDao.closeProductionControlByProductOrder(control);
  }

  private void closeProductionControlByProductionOrder(ProductionControl control) {
    OperationTask task = new OperationTask();
    task.setProductionOrderNum(control.getProductionOrderNum());
    task.setSiteCode(control.getSiteCode());
    task.setStatusECode(OperationTaskStatus.CLOSE.getValue());
    task.setStatusECode1(OperationTaskStatus.COMPLETE.getValue());
    setChangeInfo(task);
    List<OperationTask> tasks = operationTaskDao.selectCanClosedOperationTaskByProductionOrder(task);
    if (tasks != null && tasks.size() > 0) {
      operationTaskDao.closeOperationTaskByProductionOrder(task);
    }
    productionControlDao.closeProductionControlByProductionOrder(control);
  }

  @Override
  public Set<String> getIssuedProductionOrder(String siteCode, String[] orderNums) {
    return productionControlDao.getIssuedProductionOrder(siteCode, orderNums);
  }

  @Override
  public List<ProductionControl> getProductionControlsByControlNums(String siteCode, String[] controlNums) {
    return productionControlDao.getProductionControlsByControlNums(siteCode, controlNums);
  }

  @Override
  public void insertProductionControl(ProductionControl productionControl) {
    productionControl.setProductionControlNum(numberRuleService.selectNextNumber(productionControl.getSiteCode(),
        NumberRuleEnums.PRODUCTIONCONTROLNO.getValue()));
    productionControlDao.insertProductionControl(productionControl);
    // 更新订单状态
    productionControl.setStatuseCode(OrderStatusCode.PLACE_ORDER.getValue());
    productionOrderDao.updateProductionOrder(productionControl);
  }

  @Override
  public ProductionControl getVirtualProductionControl(String siteCode, String orderNum) {
    return productionControlDao.getVirtualProductionControl(siteCode, orderNum);
  }

  @Override
  public List<ProductionControl> getCreatedControlsByCondition(ProductionControlCondition condition) {
    return productionControlDao.getCreatedControlsByCondition(condition);
  }

  @Override
  public int getCreatedControlsCountByCondition(ProductionControlCondition condition) {
    return productionControlDao.getCreatedControlsCountByCondition(condition);
  }

}
